﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using umbraco.NodeFactory;
using Fonqi.Umbraco;

namespace SPCFMedicineInformer.UserControls
{
    public partial class AdminLeftNavigationControl : System.Web.UI.UserControl
    {        
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public string IsCurrentNode(int? menuId, bool withClassElement, bool checkChildren)
        {
            if (!menuId.HasValue) return string.Empty;
            var currentId = Node.getCurrentNodeId();
            if (checkChildren)
            {
                if (menuId.Value == currentId || NodeController.IsNodeDescendantOfNode(currentId, menuId.Value))
                    return withClassElement ? "class=\"submenu-active\"" : "submenu-active";
            }
            else
            {
                if (menuId.Value == currentId)
                    return withClassElement ? "class=\"submenu-active\"" : "submenu-active";
            }

            return string.Empty;
        }
    }
}